home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12960 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news.sprintlink.net!datalytics!usenet
  2. From: Rob Stewart <stew@datalytics.com>
  3. Newsgroups: comp.lang.c++,comp.object,comp.object.logic
  4. Subject: Re: polymorphism
  5. Date: Fri, 22 Mar 1996 13:43:23 -0500
  6. Organization: Datalytics, Inc
  7. Message-ID: <3152F4CB.2745@datalytics.com>
  8. References: <31513CBB.41C6@mi.leeds.ac.uk> <4irhd8$g1i@mo6.rc.tudelft.nl>
  9. NNTP-Posting-Host: 204.62.224.71
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (WinNT; I)
  14.  
  15. Ejo Schrama wrote:
  16. > aniko@mi.leeds.ac.uk (Aniko Simon) wrote:
  17. > >Hi;
  18. > >
  19. > >Can anyone help:
  20. > >what does the term "polymorphism" mean in OO programming ?
  21. > >
  22. > Yes, it means that a function, designed to work on a particular type
  23. > of object (or objects) also works for inhereted objects. For example:
  24. >   change(world);
  25. > where change is a function designed to work with world objects can
  26. > also be used for venus objects:
  27. >   change(venus);
  28. > where venus is inhereted from the base object world.
  29.  
  30. More accurately, it means that derived classes can (re)implement 
  31. a (pure) virtual base class function, and the correct derived 
  32. class function will be invoked based upon the type of the object 
  33. being pointed to (or referenced) rather than on the type of the 
  34. pointer (reference).
  35.  
  36. If that wasn't clear enough, let me elaborate.  If you have a 
  37. pointer to a base class, but assign it the address of a derived 
  38. class object, ordinarily, calling a function through that 
  39. pointer would invoke a base class function.  However, with 
  40. virtual functions, the derived class' function would be invoked 
  41. since the pointer actually points to a derived class object.
  42.  
  43. -- 
  44. Robert Stewart        | My opinions are usually my own.
  45. Datalytics, Inc.    | stew@datalytics.com
  46.